package com.wanxi.set;

public class Student implements Comparable<Student> {
    private String name;
    private Integer age;

    public Student() {
    }

    public Student(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        int result = this.age - o.age;
//        如果年龄一样，则再比较姓名
//        if (result == 0) {
//            对姓名进行比较
//            if (1 > 2) {
//                return 1;
//            } else {
//                return 2;
//            }
//            return this.name.compareTo(o.name);
//        } else {
//            return result;
//        }
//        return result == 0 ? this.name.compareTo(o.name) : result;
        System.out.println("aa");
        return result;
    }
}
